//
//  MusicTool.m
//  CloudMusic
//
//  Created by LiDan on 15/12/14.
//  Copyright © 2015年 com.lidan. All rights reserved.
//

#import "MusicTool.h"
#import "aRquestModel.h"

@implementation MusicTool
#define aRWeakSelf __weak typeof(self) weakSelf = self;
singleton_implementation(MusicTool)

-(NSArray *)musicList
{
    if (!_musicList){
    }
    return _musicList;
}


-(void)prepareToPlayWithMusic:(NSURL *)path{
    self.player = [[AVAudioPlayer alloc] initWithContentsOfURL:path error:nil];
    self.player.delegate = self;
    [self.player prepareToPlay];
    [self playMusic];
}

-(void)playMusic{
    [self.player play];
    self.playing = YES;
}

-(void)pauseMusic{
    [self.player pause];
    self.playing = NO;
}

-(void)audioPlayerDidFinishPlaying:(AVAudioPlayer *)player successfully:(BOOL)flag
{
    if (flag)
    {
        NSNotification *notification =[NSNotification notificationWithName:@"SendFinishMusicInfo" object:nil userInfo:nil];
        [[NSNotificationCenter defaultCenter] postNotification:notification];
    }
}



@end
